package risk.client;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import risk.client.gui.SetUpGameDialog;
import risk.client.gui.SplashDialog;
import risk.client.gui.WinnerDialog;

public class Main {
    public Thread gameThread;
    private static SplashDialog splash = new SplashDialog();
    private static SetUpGameDialog gd = new SetUpGameDialog();
    
    /**
     * @author Johan
     * @param args
     */
    public static void main(String[] args) {
        Main mainO = new Main();

        while(true) {
            splash.setVisible(true);
            if(splash.getChoice() == Risk.MODE_NEWGAME) {
                splash.setVisible(false);
                gd.setVisible(true);
                gd.waitForOk = true;
                while(gd.waitForOk) {
                    try {
                        Thread.sleep(1);
                    } catch (InterruptedException e) {
                    }
                }
                
                gd.setVisible(false);
                mainO.newRisk(Risk.MODE_NEWGAME);
                splash.unsetChoice();
            } else if(splash.getChoice() == Risk.MODE_NEWMAP) {
                splash.setVisible(false);
                mainO.newRisk(Risk.MODE_NEWMAP);
                splash.unsetChoice();
              
            }
            //else
           //     splash.repaint();
        }
    }
    
    /**
     * New risk
     * 
     * @author: Pierre
     * @param mode
     */
    public void newRisk(int mode) {
        
        Risk risk = new Risk(mode, gd);
        gameThread = new Thread(risk);
        gameThread.run();
        risk.frame.dispose();
        gameThread.interrupt();
    }
}
